package com.example.network.common;

import lombok.Data;

@Data
public class Result {
    private static final String SUCCESS_CODE="200";
    private static final String ERROR_CODE="-1";

    //包装后台数据--存到Result中
    //前端接口可以从Result的data中拿到数据
    //返回前端的属性
    private String code;
    private Object data;
    private String msg;

    //返回类
    public static Result success(){
        Result result=new Result();
        result.setCode(SUCCESS_CODE);
        return result;
    }
    public static Result success(Object data){
        Result result=new Result();
        result.setCode(SUCCESS_CODE);
        result.setData(data);
        return result;
    }
    public static Result error(String msg){
        Result result=new Result();
        result.setCode(ERROR_CODE);
        result.setMsg(msg);
        return result;
    }
}
